<template>
  <div>
    <el-menu
      :default-active="activeIndex2"
      class="el-menu-demo"
      mode="horizontal"
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b"
      @select="handleSelect"
    >
      <el-menu-item index="1">首页</el-menu-item>
      <el-sub-menu index="2">
        <template #title>Workspace</template>
        <el-menu-item index="2-1">item one</el-menu-item>
        <el-menu-item index="2-2">item two</el-menu-item>
        <el-menu-item index="2-3">item three</el-menu-item>
        <el-sub-menu index="2-4">
          <template #title>item four</template>
          <el-menu-item index="2-4-1">item one</el-menu-item>
          <el-menu-item index="2-4-2">item two</el-menu-item>
          <el-menu-item index="2-4-3">item three</el-menu-item>
        </el-sub-menu>
      </el-sub-menu>
      <el-menu-item index="3">Info</el-menu-item>
      <el-menu-item index="4">Orders</el-menu-item>
    </el-menu>
    <div class="box">
      <div class="box_menu">
        <el-menu
          id="el_menu_left"
          active-text-color="#ffd04b"
          background-color="#545c64"
          class="el-menu-vertical-demo"
          default-active="2"
          text-color="#fff"
          @open="handleOpen"
          @close="handleClose"
        >
          <el-sub-menu index="1">
            <template #title>
              <el-icon><location /></el-icon>
              <span>Navigator One</span>
            </template>
            <el-menu-item index="1-1" @click="handleButton"
              >button页面</el-menu-item
            >
            <el-menu-item index="1-2" @click="handleButton1"
              >去TablePage页</el-menu-item
            >
            <el-menu-item index="1-3" @click="handleButton2"
              >去Upload页</el-menu-item
            >
            <el-menu-item index="1-4" @click="handleButton3"
              >去grid页面</el-menu-item
            >
            <el-sub-menu index="1-4">
              <template #title>233</template>
              <el-menu-item index="1-4-1">item one</el-menu-item>
            </el-sub-menu>
          </el-sub-menu>
          <el-menu-item index="2">
            <el-icon><icon-menu /></el-icon>
            <span>Navigator Two</span>
          </el-menu-item>
          <el-menu-item index="3">
            <el-icon><document /></el-icon>
            <span>Navigator Three</span>
          </el-menu-item>
          <el-menu-item index="4">
            <el-icon><setting /></el-icon>
            <span>Navigator Four</span>
          </el-menu-item>
        </el-menu>
      </div>
      <div class="box_content">
        <p>1231</p>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { useRouter } from "vue-router";
import {
  Document,
  Menu as IconMenu,
  Location,
  Setting,
} from "@element-plus/icons-vue";

const router = useRouter();

const activeIndex = ref("1");
const activeIndex2 = ref("1");
const handleSelect = (key: string, keyPath: string[]) => {
  console.log(key, keyPath);
};
const handleButton = () => {
  router.push({ path: "./buttonPage" });
};
const handleButton1 = () => {
  router.push({ path: "./TablePage" });
};
const handleButton2 = () => {
  router.push({ path: "./Upload" });
};
const handleButton3 = () => {
  router.push({ path: "./gridPage" });
};

const handleOpen = (key: string, keyPath: string[]) => {
  console.log(key, keyPath);
};
const handleClose = (key: string, keyPath: string[]) => {
  console.log(key, keyPath);
};
</script>

<style scoped lang="scss">
body {
  margin: 0 !important;
  padding: 0;
}
#el_menu_left {
  // background-color: pink;
  height: calc(100vh - 60px);
}
.box {
  width: 100%;
  height: calc(100vh - 60px);
  display: flex;
  &_meun {
    width: 300px;
  }
  &_content {
    flex: 1;
  }
}
</style>
